﻿using NewsPortal.Modularity.Core;
using System;
using System.Collections.Generic;

namespace NewsPortal.Web.Infrastructure.Modularity
{
    public class ModuleFactory : IModuleFactory
    {
        private IModuleTypeProvider _provider;
        public ModuleFactory(IModuleTypeProvider provider)
        {
            this._provider = provider;
        }

        public IEnumerable<IModule> Get()
        {
            List<IModule> modules = new List<IModule>();
            _provider.GetComptabileTypes().ForEach(t => modules.Add((IModule)Activator.CreateInstance(t)));
            return modules;
        }
    }
}